package com.brainhealth.web.controller.customer;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.brainhealth.common.annotation.Log;
import com.brainhealth.common.core.controller.BaseController;
import com.brainhealth.common.core.domain.AjaxResult;
import com.brainhealth.common.enums.BusinessType;
import com.brainhealth.customer.domain.CustomerDifficulty;
import com.brainhealth.customer.service.ICustomerDifficultyService;
import com.brainhealth.common.utils.poi.ExcelUtil;
import com.brainhealth.common.core.page.TableDataInfo;

/**
 * 会员游戏难度Controller
 * 
 * @author ruoyi
 * @date 2023-05-30
 */
@RestController
@RequestMapping("/customer/customerDifficulty")
public class CustomerDifficultyController extends BaseController
{
    @Autowired
    private ICustomerDifficultyService customerDifficultyService;

    /**
     * 查询会员游戏难度列表
     */
    @PreAuthorize("@ss.hasPermi('customer:customerDifficulty:list')")
    @GetMapping("/list")
    public TableDataInfo list(CustomerDifficulty customerDifficulty)
    {
        startPage();
        List<CustomerDifficulty> list = customerDifficultyService.selectCustomerDifficultyList(customerDifficulty);
        return getDataTable(list);
    }

    /**
     * 导出会员游戏难度列表
     */
    @PreAuthorize("@ss.hasPermi('customer:customerDifficulty:export')")
    @Log(title = "会员游戏难度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CustomerDifficulty customerDifficulty)
    {
        List<CustomerDifficulty> list = customerDifficultyService.selectCustomerDifficultyList(customerDifficulty);
        ExcelUtil<CustomerDifficulty> util = new ExcelUtil<CustomerDifficulty>(CustomerDifficulty.class);
        util.exportExcel(response, list, "会员游戏难度数据");
    }

    /**
     * 获取会员游戏难度详细信息
     */
    @PreAuthorize("@ss.hasPermi('customer:customerDifficulty:query')")
    @GetMapping(value = "/{customerDifficultyId}")
    public AjaxResult getInfo(@PathVariable("customerDifficultyId") Long customerDifficultyId)
    {
        return success(customerDifficultyService.selectCustomerDifficultyByCustomerDifficultyId(customerDifficultyId));
    }

    /**
     * 新增会员游戏难度
     */
    @PreAuthorize("@ss.hasPermi('customer:customerDifficulty:add')")
    @Log(title = "会员游戏难度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomerDifficulty customerDifficulty)
    {
        return toAjax(customerDifficultyService.insertCustomerDifficulty(customerDifficulty));
    }

    /**
     * 修改会员游戏难度
     */
    @PreAuthorize("@ss.hasPermi('customer:customerDifficulty:edit')")
    @Log(title = "会员游戏难度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomerDifficulty customerDifficulty)
    {
        return toAjax(customerDifficultyService.updateCustomerDifficulty(customerDifficulty));
    }

    /**
     * 删除会员游戏难度
     */
    @PreAuthorize("@ss.hasPermi('customer:customerDifficulty:remove')")
    @Log(title = "会员游戏难度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{customerDifficultyIds}")
    public AjaxResult remove(@PathVariable Long[] customerDifficultyIds)
    {
        return toAjax(customerDifficultyService.deleteCustomerDifficultyByCustomerDifficultyIds(customerDifficultyIds));
    }
}
